<include file="public@header" />
</head>

<body>
    <div class="wrap">
        <ul class="nav nav-tabs">
            <li class=""><a href="{:url('leader/index',array('id'=>$id))}">项目分包组长</a></li>
            <li class="active"><a>新增组长</a></li>
        </ul>
        <form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('leader/doadd')}"
            enctype="multipart/form-data">


            <div class="form-group">
                <label class="col-sm-2 control-label">
                    <span class="form-required">*</span>姓名
                </label>
                <div class="col-md-6 col-sm-10">
                    <select name="name" id="nameSelect" class="form-control">
                        <option value=""></option>
                        <volist name="group" id="v">
                            <option value="{$v.name}">{$v.name}</option>
                        </volist>
                    </select>
                </div>
            </div>


            <div class="form-group">
                <label  class="col-sm-2 control-label">
                    <span class="form-required">*</span>工种
                </label>
                <div class="col-md-6 col-sm-10">
                    <input name="type" id="typeSelect" class="form-control" />

                    <!-- <select name="type" id="typeSelect" class="form-control">
                        <option value=""></option>
                        <volist name="group" id="v">
                            <option value="{$v.type}">{$v.type}</option>
                        </volist>
                    </select> -->
                </div>
            </div>


            <div class="form-group">
                <label for="js-smtpsecure" class="col-sm-2 control-label">
                    <span class="form-required">*</span>入职时间
                </label>
                <div class="col-md-6 col-sm-10">
                    <input type="date" class="form-control" name="insTime">
                </div>
            </div>


            <div class="form-group">
                <label for="js-smtpsecure" class="col-sm-2 control-label">
                    离职时间
                </label>
                <div class="col-md-6 col-sm-10">
                    <input type="date" class="form-control" name="outTime">
                </div>
            </div>

            <input type="hidden" name="eid" value="{$id}">



            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
                    <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                </div>
            </div>
        </form>
    </div>
    <script src="__STATIC__/js/admin.js"></script>
    <script>
        // 输出姓名与工种的映射
        var nameTypeMap = {
            <volist name="group" id="v">
                "{$v.name}": "{$v.type}"<if condition="$i neq count($group)">,</if>
            </volist>
        };

        document.addEventListener('DOMContentLoaded', function () {
            var nameSelect = document.getElementById('nameSelect');
            var typeSelect = document.getElementById('typeSelect');
            nameSelect.addEventListener('change', function () {
                var name = this.value;
                var type = nameTypeMap[name] || '';
                typeSelect.value = type;
            });
        });
    </script>

</body>

</html>